package com.icode.gulimall.cart.vo;

import lombok.Getter;
import lombok.NoArgsConstructor;
import lombok.Setter;

import java.math.BigDecimal;
import java.util.List;

/**
 * @Author: i_code
 * @Email: my_code@foxmail.com
 * @Date: 2021/1/9 11:33
 *
 * 购物项内容
 */
@NoArgsConstructor
public class CartItemVo {

    @Getter @Setter
    private Long skuId;

    @Getter @Setter
    private Boolean check = true;

    @Getter @Setter
    private String title;

    @Getter @Setter
    private String image;

    @Getter @Setter
    /**
     * 商品套餐属性
     */
    private List<String> skuAttrValues;

    @Getter @Setter
    private BigDecimal price;

    @Getter @Setter
    private Integer count;

    @Setter
    private BigDecimal totalPrice;

    /**
     * 计算当前购物项总价
     * @return
     */
    public BigDecimal getTotalPrice() {
        return this.price.multiply(new BigDecimal(this.count));
    }

    public CartItemVo(Long skuId, Integer count) {
        this.skuId = skuId;
        this.count = count;
    }
}
